//
//  OMHomeAddressSelectTableCell.m
//  OMENGO_NEW
//
//  Created by 梁尚嘉 on 2017/4/21.
//  Copyright © 2017年 Kamfat. All rights reserved.
//

#import "OMHomeAddressSelectTableCell.h"
#import "OMOriginalAddress.h"
@interface OMHomeAddressSelectTableCell ()
@property (nonatomic, strong) UIImageView *checkmarkIV;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UIView *containView;
@end


@implementation OMHomeAddressSelectTableCell

- (void)configure
{
    [super configure];

    _containView = [UIView new];
    [self.contentView addSubview:_containView];

    _checkmarkIV = [[UIImageView alloc]init];
    [self.contentView addSubview:_checkmarkIV];
    [_checkmarkIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(SM_SIZE(30)));
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(SM_SIZE(38), SM_SIZE(38)));
    }];

    [self.containView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(SM_SIZE(20)));
        make.centerY.equalTo(self.containView.mas_centerY);
    }];

    [self.containView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.checkmarkIV.mas_right).offset(SM_SIZE(10));
        make.top.bottom.right.equalTo(@0);
    }];

}

- (void)configureCellWithObj:(OMOriginalAddress*)obj
{
    [super configureCellWithObj:obj];
    self.nameLabel.text = obj.name;
}

- (void)setOm_selected:(BOOL)om_selected
{
    _om_selected = om_selected;
    NSString *imageStr = om_selected?@"address_selected_19x19_":@"nil";
    _checkmarkIV.image = [UIImage imageNamed:imageStr];
}


- (UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel = [UILabel new];
        _nameLabel.textColor = HEXCOLOR(@"#656565");
        _nameLabel.font = SM_CFont(27);
    }
    return _nameLabel;
}

+ (CGFloat)cellHeight
{
    return SM_SIZE(90);
}
@end
